package communicationMessages;

import java.util.Set;
import java.util.logging.Level;

import logger.LoggerWriter;
import database.DB;

public class CandidatesModeratorsMessage extends Message {

	@Override
	public String getAnswer() {
		String[] arr = this.content.split(delimiter);
		LoggerWriter logger = LoggerWriter.getLoggerWriter();
		String ans = "CandidatesList"+delimiter;
		if (arr.length != 2)
		{
			logger.log("failed"+delimiter+"Candidates Moderator Message wrong format"+delimiter, Level.WARNING);
			ans = "failed"+delimiter+"Candidates Moderator Message wrong format"+delimiter;
		}
		else
		{
			String userName , subForumID;
			userName = arr[0];
			subForumID = arr[1];
			if (DB.isAdmin(userName))
			{
				ans+="admin" + delimiter;
				Set<String> candidates = DB.getCandidateList(subForumID);
				for (String candidateName : candidates) {
					ans+=candidateName + delimiter;
				}
			}

		}
		System.out.println("ans is: "+ans);
		return ans;
	}
	
//	Forum forum = Forum.getForum();
//	ans +=  MemberDataBase.getUserRoll(userName)+delimiter;
//	Vector<Member> candidates = forum.getPossibleModeratorForForum(subForumInt);
//	for (Member moderator : candidates) {
//		ans+=moderator.get_name()+delimiter;
//	}
}
